<?php

class Social_Group_Member extends Social_Base
{
    public function init()
    {
        $this->setTableName('group_members');
        $this->setPrimaryKey('member_id');
    }

    public function hasMember($groupId, $userId)
    {
        return $this->exists(array('group_id' => $groupId, 'user_id' => $userId));
    }

    public function checkMember($groupId, $userId)
    {
        if(!$this->hasMember($groupId, $userId) {
            throw new InvalidArgumentException('You are not a member of group: ' . $groupId);
        }
        return true;
    }
}
